import requests
import time

# 发送请求
def send(id,password):
  url = "http://172.16.2.9:8080/eportal/InterFace.do?method=login&userId="+id+"&password="+password+"&queryString=wlanuserip%3D4728b530577b6dbb84243d87d33c20d9%26wlanacname%3Db3b3dd674434a9db70df973004a20ca6%26ssid%3D%26nasip%3D7b3ad2fa097d34acd2131b2fd77ea6f0%26snmpagentip%3D%26mac%3D93489a207779817531aaf8db14aa1476%26t%3Dwireless-v2%26url%3D709db9dc9ce334aa02a9e1ee58ba6fcf3bc3349e947ead368bdd021b808fdbac30c65edaa96b0727%26apmac%3D%26nasid%3Db3b3dd674434a9db70df973004a20ca6%26vid%3Dce3558e0b2a8a823%26port%3D9bdeca5efa34f87c%26nasportid%3Df5eb983692924fa26e6431fe9df4835f02c7eedb2507238a361fd6feccf083ac7d930a603cb25e71&passwordEncrypt=false"
  flag=0

  while True:
    try:
      flag+=1
      if flag>5:
        print("尝试次数过多，请检查网络连接")
        break
      print("当前账号为",id)
      res = requests.post(url)
      if(res.json()['result']=='success'):
        print("登录成功")
        break
      else:
        print("登录失败,请查看错误代码")
        print(res.json()['text'])
        input("请按任意键继续")
    except Exception as e:
      print("出问题了！连接错误···")
      print(e)
      time.sleep(5)
  
  print("倒计时:3")
  time.sleep(1)
  print("倒计时:2")
  time.sleep(1)
  print("倒计时:1")
  time.sleep(1)
  return

#需自己修改xxx
UserId = "xxxxxxxxxx" #账号(学号)
PassWord = "xxxxxx" #密码(身份证后六位)
send(UserId,PassWord)



